<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

        <h:form id="BarrioListForm">

            <p:panel header="#{myBundle.ListBarrioTitle}">
                <p:contextMenu id="BarrioDataTableContextMenu" for="datalist">  
                    <p:menuitem value="#{myBundle.Create}" onclick="document.getElementById('BarrioListForm:createButton').click();" icon="ui-icon-plus"/>
                    <p:menuitem value="#{myBundle.View}" onclick="document.getElementById('BarrioListForm:viewButton').click();" icon="ui-icon-search"/>
                    <p:menuitem value="#{myBundle.Edit}" onclick="document.getElementById('BarrioListForm:editButton').click();" icon="ui-icon-pencil"/>
                    <p:menuitem value="#{myBundle.Delete}" onclick="document.getElementById('BarrioListForm:deleteButton').click();" icon="ui-icon-trash"/>
                    <p:separator/>
                    <p:menuitem value="#{myBundle.BarrioMenuItem_partidoId}" icon="ui-icon-search"  actionListener="#{barrioController.preparePartidoId}" update=":PartidoViewForm" oncomplete="PartidoViewDialog.show()" disabled="#{empty barrioController.selected.partidoId}"/>  
                    <p:menuitem value="#{myBundle.BarrioMenuItem_nomenclaturaOrigenId}" icon="ui-icon-search"  actionListener="#{barrioController.prepareNomenclaturaOrigenId}" update=":NomenclaturaCatastralViewForm" oncomplete="NomenclaturaCatastralViewDialog.show()" disabled="#{empty barrioController.selected.nomenclaturaOrigenId}"/>  
                    <p:menuitem value="#{myBundle.BarrioMenuItem_datoDelDominioId}" icon="ui-icon-search"  actionListener="#{barrioController.prepareDatoDelDominioId}" update=":DatoDelDominioViewForm" oncomplete="DatoDelDominioViewDialog.show()" disabled="#{empty barrioController.selected.datoDelDominioId}"/>  
                    <p:menuitem value="#{myBundle.BarrioMenuItem_expedienteCollection}" icon="ui-icon-search"  action="#{barrioController.navigateExpedienteCollection}" disabled="#{empty barrioController.selected.expedienteCollection}" ajax="false"/>  
                </p:contextMenu>
                <p:dataTable id="datalist"
                             value="#{barrioController.items}"
                             var="item"
                             rowKey="#{item.id}"
                             paginator="true"
                             rows="10"
                             rowsPerPageTemplate="10,20,30,40,50"
                             selectionMode="single"
                             selection="#{barrioController.selected}">

                    <p:ajax event="rowSelect"   update=":BarrioListForm:createButton :BarrioListForm:viewButton :BarrioListForm:editButton :BarrioListForm:deleteButton :BarrioListForm:BarrioDataTableContextMenu" listener="#{barrioController.resetParents}"/>
                    <p:ajax event="rowUnselect" update=":BarrioListForm:createButton :BarrioListForm:viewButton :BarrioListForm:editButton :BarrioListForm:deleteButton :BarrioListForm:BarrioDataTableContextMenu" listener="#{barrioController.resetParents}"/>
                    <p:ajax event="rowDblselect" onsuccess="document.getElementById('BarrioListForm:viewButton').click();"/>

                    <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_id}"/>
                        </f:facet>
                        <h:outputText value="#{item.id}"/>
                    </p:column>


                    <p:column sortBy="#{item.nombre}" filterBy="#{item.nombre}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_nombre}"/>
                        </f:facet>
                        <h:outputText value="#{item.nombre}"/>
                    </p:column>


                    <p:column sortBy="#{item.direccionDeReferencia}" filterBy="#{item.direccionDeReferencia}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_direccionDeReferencia}"/>
                        </f:facet>
                        <h:outputText value="#{item.direccionDeReferencia}"/>
                    </p:column>


                    <p:column sortBy="#{item.partidoId.id}" filterBy="#{item.partidoId.id}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_partidoId}"/>
                        </f:facet>
                        <h:outputText value="#{item.partidoId.id}"/>
                    </p:column>


                    <p:column sortBy="#{item.nomenclaturaOrigenId.id}" filterBy="#{item.nomenclaturaOrigenId.id}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_nomenclaturaOrigenId}"/>
                        </f:facet>
                        <h:outputText value="#{item.nomenclaturaOrigenId.id}"/>
                    </p:column>


                    <p:column sortBy="#{item.datoDelDominioId.id}" filterBy="#{item.datoDelDominioId.id}">
                        <f:facet name="header">
                            <h:outputText value="#{myBundle.ListBarrioTitle_datoDelDominioId}"/>
                        </f:facet>
                        <h:outputText value="#{item.datoDelDominioId.id}"/>
                    </p:column>


                </p:dataTable>

                        <p:commandButton id="createButton"                             icon="ui-icon-plus"   value="#{myBundle.Create}" actionListener="#{barrioController.prepareCreate}" update=":BarrioCreateForm" oncomplete="BarrioCreateDialog.show()"/>
                        <p:commandButton id="viewButton"   style="visibility: hidden;" icon="ui-icon-search" value="#{myBundle.View}" update=":BarrioViewForm" oncomplete="BarrioViewDialog.show()" disabled="#{empty barrioController.selected}"/>
                        <p:commandButton id="editButton"   style="visibility: hidden;" icon="ui-icon-pencil" value="#{myBundle.Edit}" update=":BarrioEditForm" oncomplete="BarrioEditDialog.show()" disabled="#{empty barrioController.selected}"/>
                        <p:commandButton id="deleteButton" style="visibility: hidden;" icon="ui-icon-trash"  value="#{myBundle.Delete}" actionListener="#{barrioController.delete}" update=":growl,datalist" disabled="#{empty barrioController.selected}"/>

            </p:panel>
        </h:form>

</ui:composition>